home *** CD-ROM | disk | FTP | other *** search
Java Source | 2002-07-11 | 3.2 KB | 91 lines |
- import com.sybase.dpb.*;
- import com.softtreetech.scheduler.*;
-
- public class example {
-
- public static void main(String arg[]) {
-
- // 1. Define global variables for JDPB_Connection and jdpb_24x7 classes:
- JDPB_Connection myConnection = null;
- jdpb_24x7 myRemoteControl = null;
-
-
-
- // 2. Instantiate the JDPB_Connection class and establish a new connection by passing
- // arguments to the JDPB_Connection connect method:
-
- Integer portNo = new Integer(1096);
- String hostName = new String("LocalHost");
- String userID = new String("scott");
- String userPass = new String("tiger");
- String serial = new String("00000-00000");
- String connectString = new String("");
- myConnection = new JDPB_Connection();
-
- try {
- myConnection.connect(hostName,
- portNo.intValue(), userID,
- serial, connectString);
- } catch(java.lang.Throwable e) {
- System.out.println( "Exception: " + e.getMessage() );
- return;
- } // end catch
-
-
-
- // 3. Instantiate the 24x7 Remote Control proxy class, passing the JDPB_Connection instance to
- // the constructor:
- myRemoteControl = new jdpb_24x7(myConnection);
-
-
-
- // 4. Call user 24x7 Remote Control functions from the Java application:
- try {
- // Open new session
- String terminal = new String("");
- Boolean htmlFormat = new Boolean(true);
-
- Integer ReturnValue =
- myRemoteControl.opensession( terminal, userID, userPass, serial );
-
- if (ReturnValue.intValue() == 1) {
- // Ok. Connection opened, session started successfully,
- // now we can do the scheduling things...
-
- // Change start time for job #12 to 6:00 AM
- ReturnValue = myRemoteControl.setjobproperty( "12", "START_TIME", "6:00" );
- } // end if
-
- if (ReturnValue.intValue() == 1) {
- // Ok. Job #12 START_TIME property changed successfully,
- // now let's get the job list in HTML format
-
- StringHolder jobList = new StringHolder("");
- ReturnValue = myRemoteControl.getjoblist( jobList, htmlFormat );
-
- if (ReturnValue.intValue() == 1) {
- // print the job list
- System.out.println( jobList.getValue() );
- } // end if
- } // end if
-
- if (ReturnValue.intValue() < 0) {
- // Handle the error
- System.out.println(myRemoteControl.getLasterror());
- } // end if
-
- // Close session
- myRemoteControl.closesession( );
- } //end try
-
- catch (com.sybase.dpb.RemoteException e) {
- System.out.println( "RemoteException exception: " + e.getMessage() );
- } // end catch
-
-
-
- // 5. Disconnect from the 24x7 Scheduler server:
- myConnection.disconnect();
-
- }
- }